﻿@inject Microsoft.Extensions.Diagnostics.ITelemetryClient TelemetryClient
@inject SubstrateOptions SubstrateOptions 
@if (!ViewData.ContainsKey("BigTitle"))
{
    ViewData["BigTitle"] = SubstrateOptions.SiteName;
}
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>@ViewData["Title"] - @ViewData["BigTitle"]</title>
    <meta name="viewport" content="initial-scale=1, user-scalable=no">
    <!-- telemetry -->@Html.Raw(TelemetryClient.GetHeadJavascript())
    <!-- jquery --><script src="~/lib/jquery/jquery.min.js"></script>
    <!-- twitter-bootstrap --><link rel="stylesheet" href="~/lib/bootstrap/css/bootstrap.min.css" /><script src="~/lib/bootstrap/js/bootstrap.bundle.min.js"></script>
    <!-- font-awesome --><link rel="stylesheet" href="~/lib/font-awesome/css/all.min.css" />
    <!-- DOMjudge style and scripts --><link rel="stylesheet" href="~/lib/xylab/domjudge.css?v=@SubstrateOptions.Version" /><script src="~/lib/xylab/domjudge.js?v=@SubstrateOptions.Version"></script><script src="~/lib/xylab/xylab.js?v=@SubstrateOptions.Version"></script>
    <!-- datatables --><link rel="stylesheet" href="~/lib/datatables/css/dataTables.bootstrap4.min.css"><script src="~/lib/datatables/js/jquery.dataTables.min.js"></script><script src="~/lib/datatables/js/dataTables.bootstrap4.min.js"></script>
    <!-- katex --><link rel="stylesheet" href="~/lib/katex/katex.min.css" /><script src="~/lib/katex/katex.min.js"></script>
</head>

<body class="@(ViewData.ContainsKey("CompactMode") ? "body-compact-theme" : "") @(ViewData.ContainsKey("UseCardTheme") ? "body-card-theme" : "") @ViewData["CustomBodyClass"]">
    <div id="append-parent"></div>
    <!-- #header start -->
    @{ var theme = ViewData.ContainsKey("UseLightTheme") ? "light" : "dark"; }
    <nav class="navbar navbar-expand-md navbar-@theme bg-@theme fixed-top">
        <partial name="_NavLogo" />

        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#menuDefault"
                aria-controls="menuDefault" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>

        <div class="collapse navbar-collapse" id="menuDefault" data-update-url="@ViewData["AjaxUpdateUrl"]">
            <partial name="_NavLinks" />
            @RenderSection("Clocking", required: false)
        </div>
    </nav>
    <!-- #content start -->
    @RenderSection("Banner", required: false)
    <div class="container-fluid">
        <div class="row">
            <div class="col-12">
                <partial name="_StatusMessage" model="@TempData["StatusMessage"]" />
                @RenderSection("Header", required: false)
                @if (!ViewData.ContainsKey("RefreshSpan"))
                {
                    @RenderBody()
                }
                else
                {
                    <div data-ajax-refresh-target data-ajax-refresh-after="@ViewData["RefreshAfter"]" data-ajax-refresh-before="@ViewData["RefreshBefore"]" class="@ViewData["DataAjaxClass"]">
                        @RenderBody()
                    </div>
                }
                @RenderSection("Footer", required: false)
            </div>
        </div>
    </div>
    @RenderSection("BannerFooter", required: false)
    <!-- #content end -->
    <div id="ajax_append"></div>
    <aside class="col-md-4 col-xl-3 pb-3" id="notification-box"></aside>

    <script asp-viewdata-key="RefreshSpan">
        $(function () {
            /* toggle refresh if set */
            $('#refresh-navitem').on('click', function() {
                toggleRefresh('@Html.Raw(ViewData["RefreshUrl"])', @ViewData["RefreshSpan"], 1);
            });

            /* Enable page refresh if set if wanted by the page, and wanted by the user */
            enableRefresh('@Html.Raw(ViewData["RefreshUrl"])', @ViewData["RefreshSpan"], 1);
        });
    </script>

    <script asp-viewdata-key="AjaxUpdateUrl">
        $(function () {
            updateMenuAlerts();
            setInterval(updateMenuAlerts, 20000);
        });
    </script>

    @RenderSection("Scripts", required: false)
</body>
</html>
